<template>
    <div style="width: 100%">
        <div id="deawer">
            <v-tableTitle :btnConfig="btnConfig" @cancel="cancel" @save="save"
                          @verifyClose="verifyClose"></v-tableTitle>
            <div class="detailBox">
                <v-detail ref="detail"></v-detail>
            </div>
            <div class="detailListBox">
                <v-detailList ref="detailList"></v-detailList>
            </div>
        </div>
    </div>

</template>

<script>
    import baseMixin from "@/mixins/BaseMixin";
    import skipMixin from "@/mixins/SkipMixin";
    import tableTitle from "commons/TableTitle";
    import detail from "../details/Detail";
    import detailList from "../detailsList/DetailList";
    import config from "../Config";


    export default {
        name: "verifyCloseDeawer",
        mixins: [baseMixin, skipMixin, config],
        data() {
            return {};
        },
        computed: {
            btnConfig() {
                return [
                    {label: this.$t('common.save'), certigier: this.saveStatus||!this.btnPermNameList.includes('WM010204'), invalid: "save"},
                    {label: this.$t('in.verifyClose'), certigier: this.verifycloseStatus||!this.btnPermNameList.includes('WM010202'), invalid: "verifyClose"},
                    {label: this.$t('common.return'), certigier: !this.btnPermNameList.includes('WM010203'), invalid: "cancel"},
                ]
            }
        },
        created() {
        },
        methods: {
            async verifyClose() {
                let arr = [];
                arr.push(this.$store.state.routeData);
                try {
                    let res = await this.$api.post('/excuteVerifyclose', arr);
                    
                        this.$message.success(res.returnMgr);
                        this.cancel();
                    
                } catch (e) {
                    this.$message.error(e)
                }
            },
            //保存按钮
            async save() {
                let detail = this.$refs.detail.detailData;
                let flag = this.$refs.detail.$children[0].$refs.input.submitForm("from");
                if (!flag) {
                    return;
                }
                try {
                    let res = await this.$api.post('/saveShipStore', detail);
                    
                        this.$message.success(res.returnMgr);
                    
                } catch (e) {
                    this.$message.error(e)
                }
            },
            //弹框取消
            cancel() {
                this.$router.push({name: "verifyClose"});
            },
        },
        watch: {},
        components: {
            "v-tableTitle": tableTitle,
            "v-detail": detail,
            "v-detailList": detailList,
        }
    }
</script>

<style scoped>

</style>
